﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Farigola.Engine.SystemData.Entity.Type;

namespace Farigola.Engine.TestUnit
{
    /// <summary>
    /// Find/extract built-in types entity directly from the wksp,
    /// no project is present.
    /// </summary>
    [TestFixture]
    public class EntityTypeTestUnit
    {
        [Test]
        public void findTypeFolderByName()
        {
            Engine engine = EngineCommonTestUnit.CreateInitEngine();
            Workspace wksp = engine.GetWorkspace();

            EntTypeBase typeBase;

            // the type string is a builtIn type
            typeBase = wksp.FindEntTypeBaseByName("folder");
            Assert.IsNotNull((typeBase as EntTypeFolder), "The type 'folder' should be found by the name.");
        }

        [Test]
        public void findTypeStringByName()
        {
            Engine engine = EngineCommonTestUnit.CreateInitEngine();
            Workspace wksp = engine.GetWorkspace();

            EntTypeBase typeBase;

            // the type string is a builtIn type
            typeBase = wksp.FindEntTypeBaseByName("string");
            Assert.IsNotNull((typeBase as EntTypeString), "The type 'string' should be found by the name.");
        }

        /// <summary>
        /// the ent type folder, string,.. exists but not the type class.
        /// The type class is a meta-data/meta-type, is not a type. 
        /// User will create type class (exp:Person, Address,...)
        /// </summary>
        [Test]
        public void findTypeClassByNameNotPossible()
        {
            Engine engine = EngineCommonTestUnit.CreateInitEngine();
            Workspace wksp = engine.GetWorkspace();

            EntTypeBase typeBase;

            // the type string is a builtIn type
            typeBase = wksp.FindEntTypeBaseByName("class");
            Assert.IsNull((typeBase as EntTypeClass), "The type 'class' should be not found by the name.");
        }

        [Test]
        public void findTypeStructListByName()
        {
            Engine engine = EngineCommonTestUnit.CreateInitEngine();
            Workspace wksp = engine.GetWorkspace();

            EntTypeBase typeBase;

            // the type string is a builtIn type
            typeBase = wksp.FindEntTypeBaseByName("list");
            Assert.IsNotNull((typeBase as EntTypeStructList), "The type 'list' should be found by the name.");
        }

        // type Int

        // get list of available ent type: folder, string, struct list,...
        // List<EntityType> findAllBuiltInEntType()  

    }
}
